import 'package:flutter/material.dart';
import 'package:cook_dinner/config/include.dart';

class SignatureNav extends StatefulWidget {
  const SignatureNav({Key? key}) : super(key: key);

  @override
  State<SignatureNav> createState() => _SignatureNavState();
}

class _SignatureNavState extends State<SignatureNav> {
  final List<String> navs = ['全部商品', '热门兑换', '卡券专区', '新品推荐'];
  int _current = 0;
  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.only(left: 44.rpx, right: 48.rpx, bottom: 10.rpx),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: List.generate(
          navs.length,
          (index) {
            return InkWell(
              onTap: () {
                setState(() {
                  _current = index;
                });
              },
              child: Text(
                navs[index],
                style: TextStyle(
                  fontSize: _current == index ? 18.rpx : 16.rpx,
                  color: _current == index
                      ? const Color(0xffFA8303)
                      : const Color(0xffA6A7A2),
                ),
              ),
            );
          },
        ),
      ),
    );
  }
}

class ProductBox extends StatelessWidget {
  const ProductBox({Key? key, this.children}) : super(key: key);

  final List<Widget>? children;

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      margin: EdgeInsets.symmetric(horizontal: 35.rpx),
      padding: EdgeInsets.symmetric(vertical: 12.rpx, horizontal: 5.rpx),
      decoration: BoxDecoration(
        border: Border(
          top: BorderSide(
            width: 1.rpx,
            color: const Color(0xffE6E3E3),
          ),
        ),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: children ?? [],
      ),
    );
  }
}

class ProductItem extends StatelessWidget {
  const ProductItem({Key? key, this.img, this.name, this.pint})
      : super(key: key);

  final String? img;
  final String? name;
  final String? pint;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        ClipRRect(
          borderRadius: BorderRadius.circular(12.rpx),
          child: Image.asset(
            'assets/images/product0$img.png',
            width: 140.rpx,
            height: 100.rpx,
          ),
        ),
        SizedBox(height: 10.rpx),
        Text(
          name ?? '',
          style: TextStyle(
            color: const Color(0xff333333),
            fontSize: 16.rpx,
          ),
        ),
        SizedBox(height: 10.rpx),
        Text(
          '$pint积分',
          style: TextStyle(
            color: const Color(0xffFA8303),
            fontSize: 20.rpx,
          ),
        ),
      ],
    );
  }
}
